import Vue from 'vue'
import Router from 'vue-router'

import login from '@/components/login.vue'
import home from '@/components/home.vue'
import zhuce from '@/components/zhuce.vue'
import booklist from '@/components/booklist.vue'
import yonghu from '@/components/yonghu.vue'
import welcome from '@/components/welcome.vue'
import jieyue from '@/components/jieyue.vue'
import bumen from '@/components/bumen.vue'
import caidan from '@/components/caidan.vue'
import book from '@/components/book.vue'
import loginhead from '@/components/loginhead.vue'


Vue.use(Router) // 注册vue-router
//根目录是登录页面
export default new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: login
    },
    {
      path: '/home',
      name: 'home',
      component: home,
      redirect:'/welcome',
        children: [
          {path:'/welcome',component: welcome},
          {path: '/booklist',component: booklist,},
          {path:'/jieyue', component: jieyue},
          {path:'/bumen',component: bumen},
          {path: '/caidan', component: caidan},
          {path: '/yonghu', component: yonghu }, 
          {path:'/book',component:book}
        ] ,
        meta:{
          keepAlive:true
        },
    },
    {
      path: '/zhuce',
      name: 'zhuce',
      component: zhuce
    },
    {
      path:'/loginhead',
      name:'loginhead',
      component: loginhead
    },

  ]
 
})
// router.beforeEach( (to,form,next)=>{
//   if(to.path === '/login' )return next()
//   window.localStorage.getItem(name)
// })